Set

The Set method sets a named value in the registry. If the key portion of the specified named value does not already exist, the Set method adds the key and any specified subkeys to the registry. The Set method supports the named-value data types REG_SZ and REG_DWORD.

Syntax

Set FullKeyValueName, Value [,Flush]

Parameters

FullKeyValueName
A string that specifies the named value. This string should consist of a key name followed by a value name. For example, to specify the value MyValue stored in the key HKLM\Software\MyCompany, you would use the following string:

HKLM\Software\MyCompany\MyValue

The key portion of this parameter can be a key on either a local or a remote machine. Keys on a remote machine are specified by prefixing the key name with the machine name. For example:

\\RemoteMachine\HKLM\Software\MyProg


Value
A VARIANT that specifies the new named value in the registry.
Flush
This optional parameter is a BOOLEAN that specifies whether the registry changes that this method makes should be immediately written to the disk.

If Flush is set to TRUE, the method immediately writes the registry changes to the disk. Note that explicitly flushing registry changes to the disk may reduce server performance.

If Flush is FALSE, the method does not write the registry changes to the disk. They are instead written to disk by the registry's lazy flusher or when the system shuts down.

The default is FALSE.

Example

The following example sets the named value MyNumber of the registry key HKLM\Software\MyCompany\ to 12345 and the named value MyString to "hello, world".

Note that in the first call to the Set method, the Flush parameter is set to TRUE. In the second call to the Set method, the Flush parameter is not specified, causing the default value of FALSE to be used.
<% 
Set Reg = Server.CreateObject("IISSample.Registry")
 
Reg.Set "HKLM\Software\MyCompany\MyNumber", 12345, True
Reg.Set "HKLM\Software\MyCompany\MyString", "hello, world"
%>
 

Applies To

Registry Access Component

See Also

Get, SetExpand